package com.wmh.baseservice.operationaid.convert.product;

import com.wmh.baseservice.operationaid.entity.ProductMonitorRecord;
import com.wmh.baseservice.operationaid.pojo.vo.product.monitorrecored.ProductMonitorRecordCommitReqVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 谢骏
 * @date 2023/9/26 14:49
 **/
@Mapper
public interface ProductMonitorRecordConvert {

    ProductMonitorRecordConvert INSTANCE = Mappers.getMapper(ProductMonitorRecordConvert.class);


    default List<ProductMonitorRecord> convertList(ProductMonitorRecordCommitReqVO reqVO) {
        return reqVO.getDateItemList().stream().map(item ->
                new ProductMonitorRecord()
                        .setAdId(reqVO.getAdId())
                        .setPushUnitId(reqVO.getPushUnitId())
                        .setProductId(reqVO.getProductId())
                        .setSkuId(item.getSkuId()).setSkuContent(item.getSkuContent())
                        .setPrice(item.getPrice())
        ).collect(Collectors.toList());
    }
}
